//
//  Kylin_MeViewController.m
//  03-BuDeJie-2 TabBar设置
//
//  Created by Kylin on 16/1/29.
//  Copyright © 2016年 kylin. All rights reserved.
//

#import "Kylin_MeViewController.h"
#import "Kylin_SettingViewController.h"
#import "Kylin_MeFooterView.h"
#import "Kylin_MeTableViewCell.h"
#import <MJRefresh.h>

static NSString * const Kylin_MeCellID = @"me";

@implementation Kylin_MeViewController


- (void)viewDidLoad{
    [super viewDidLoad];
    
    // 设置导航栏显示的内容
    [self setupNav];
   
    [self setupTableVC];
   
}


- (void)setupNav{
    self.navigationItem.title = @"我的";
    UIBarButtonItem *mButton = [UIBarButtonItem itemWithImage:@"mine-moon-icon" hightImage:@"mine-moon-icon-click" target:self action:@selector(moonButtonClick)];
    
    UIBarButtonItem *sButton = [UIBarButtonItem itemWithImage:@"mine-setting-icon" hightImage:@"mine-setting-icon-click" target:self action:@selector(settingButtonClick)];
    
    self.navigationItem.rightBarButtonItems = @[sButton,mButton];
    
}

- (void)setupTableVC{
    
    self.tableView.backgroundColor = Kylin_CommonBgColor;
    
    // 注册CELL
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:Kylin_MeCellID];
    
    // 设置每一组的关部高度
    self.tableView.sectionHeaderHeight = 0;
    // 设置每一组的尾部高度
    self.tableView.sectionFooterHeight = Kylin_CommonMargin;
    
    // 设置内边距(- 25 所有内空都会向上移动25)
    self.tableView.contentInset = UIEdgeInsetsMake(Kylin_CommonMargin - 35, 0, 0, 0);
    self.tableView.showsVerticalScrollIndicator = NO;
    
    // 设置FOOTER

    self.tableView.tableFooterView = [[Kylin_MeFooterView alloc]init];
   
}

- (void)moonButtonClick{
    
    Kylin_LogFunc;
}


#pragma mark- 跳转到设置介面
- (void)settingButtonClick{
  
    Kylin_SettingViewController *vc = [[Kylin_SettingViewController alloc]initWithStyle:UITableViewStyleGrouped];
    
    [self.navigationController pushViewController:vc animated:YES];
}



// 分为两组,
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}

// 线组一行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}


// 设置cell 内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    Kylin_MeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Kylin_MeCellID];
    
    if (indexPath.section == 0) {
        cell.textLabel.text = @"登陆/注册";
        cell.imageView.image = [UIImage imageNamed:@"setup-head-default"];
        
    }else{
        cell.textLabel.text = @"离线下载";
    }
   
    return cell;
}



@end
